package com.hentai.androidserver.controller;

import com.hentai.androidserver.domain.Users;
import com.hentai.androidserver.service.UsersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping(value = "/user")
public class UsersController {

    @Resource
    UsersService usersService;

    @PostMapping(value = "/login")
    public Users login(@RequestBody Users users) {
        log.info("{}", users);

        users = usersService.login(users);

        if (users == null) {
            return new Users();
        }

        return users;
    }

    @PostMapping(value = "/register")
    public Users register(Users users) {
        return users;
    }

}
